package models

import (
	"commonService"
	"errors"
)

var (
	Aircrafts map[string]*commonService.AircraftInfo
)

func init() {
	Aircrafts = make(map[string]*commonService.AircraftInfo)
	Aircrafts["23"] = &commonService.AircraftInfo{"23", 1.1, 2.2, 3.3, 4.4, 5.5}
	Aircrafts["45"] = &commonService.AircraftInfo{"45", 6.6, 7.7, 8.8, 9.9, 0.0}
}

func AddOne(aircraft commonService.AircraftInfo) (id string) {
	Aircrafts[aircraft.ID] = &aircraft
	return aircraft.ID
}

func GetOne(id string) (aircraft *commonService.AircraftInfo, err error) {
	if v, ok := Aircrafts[id]; ok {
		return v, nil
	}
	return nil, errors.New("id Not Exist")
}

func GetAll() map[string]*commonService.AircraftInfo {
	return Aircrafts
}

//func Update(id string, Score int64) (err error) {
//	if v, ok := Objects[ObjectId]; ok {
//		v.Score = Score
//		return nil
//	}
//	return errors.New("ObjectId Not Exist")
//}

func Delete(id string) {
	delete(Aircrafts, id)
}
